package com.example.bishe.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.bishe.entity.Approval;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.bishe.web.b.vo.getApprovalPageVO;
import com.example.bishe.web.b.vo.getRoomPageVO;
import com.example.bishe.web.c.vo.UserApprovalVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author LDH
 * @since 2022/11/30
 */
@Mapper
public interface ApprovalMapper extends BaseMapper<Approval> {

    IPage<UserApprovalVO> getUserApproval(
            IPage<UserApprovalVO> page,
            @Param("userId") Long userId
    );

    @Select("SELECT * FROM approval WHERE user_id=#{userId} AND type=#{type} AND room_id=#{roomId}")
    Approval getApprovalByOne(
            @Param("userId") Long userId,
            @Param("roomId") Long roomId,
            @Param("type") Integer type
    );

    IPage<getApprovalPageVO> getPage(
            IPage<getApprovalPageVO> page,
            @Param("id") Long id,
            @Param("userId") Long userId,
            @Param("userName") String userName,
            @Param("result") Integer result,
            @Param("startTime") String startTime,
            @Param("endTime") String endTime
    );

}
